package cn.novel.bm.controller.novel;

import cn.novel.bm.domain.novel.Novel;
import cn.novel.bm.util.ResponseResult;
import io.swagger.annotations.*;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * Created on 2020/7/16 12:37 下午
 *
 * @author barry
 * Description:
 */
//@RequestMapping(value = "/novel", produces = MediaType.APPLICATION_JSON_VALUE)
//@RestController
//@Api(tags = "小说管理")
//@SecurityScheme(name = "BearerAuthCookie"
//        , type = SecuritySchemeType.APIKEY
//        , in = SecuritySchemeIn.COOKIE
//        , paramName = "apiKey")
public class NovelController {

    @ResponseStatus(code = HttpStatus.CREATED)
    @PostMapping(path = "/")
    @ApiOperation(value = "创建小说")
    public ResponseResult<Void> create(@RequestBody Novel novel) {
        return new ResponseResult<>();
    }


    @GetMapping(path = "/{novelId}")
    @ApiOperation(value = "查询小说")
    public ResponseResult<Novel> query(@PathVariable int novelId) {
        return new ResponseResult<>();
    }

    @DeleteMapping(path = "/{novelId}")
    @ApiOperation(value = "删除小说")

    public ResponseResult<Void> delete(@PathVariable int novelId) {
        return new ResponseResult<>();
    }

    @ApiOperation(value = "小说查询列表")
    @GetMapping(path = "/findList")

    public ResponseResult<List<Novel>> findList(@RequestParam @ApiParam(value = "页码") int pageIndex, @RequestParam @ApiParam(value = "每页条数") int pageSize) {
        return new ResponseResult<>();
    }

    @ApiOperation(value = "指派责编", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
    @PostMapping(path = "/assignREditor", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "novelId", paramType = "formData"),
            @ApiImplicitParam(name = "userId", paramType = "formData"),

    })
    public ResponseResult<Void> assignResponsibleEditor(@RequestParam @ApiParam(value = "小说ID") int novelId
            , @RequestParam @ApiParam(value = "用户名") int userId) {
        return new ResponseResult<>();
    }

    @ApiOperation(value = "上传原文", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    @PostMapping(path = "/uploadSource", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "novelId", paramType = "formData", dataType = "integer"),
            @ApiImplicitParam(name = "file", paramType = "formData", dataType = "file"),

    })
    @ResponseBody
    public ResponseResult<Void> uploadSource(@RequestParam int novelId
            , @RequestPart("file") MultipartFile file, HttpServletRequest request) {
        return new ResponseResult<>();
    }

    @ApiOperation(value = "解析章节", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
    @PostMapping(path = "/parseChapters", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "novelId", paramType = "formData"),

    })
    public ResponseResult<Void> parseChapters(@RequestParam @ApiParam(value = "小说ID") int novelId) {
        return new ResponseResult<>();
    }
}
